<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title>东家帮-添加房源</title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="format-detection" content="telephone=no">
	<meta name="renderer" content="webkit">
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="alternate icon" type="image/png" href="${base}/amazeui/assets/i/favicon.png">
	<link rel="stylesheet" href="${base}/css/common.css"/>
	<link rel="stylesheet" href="${base}/amazeui/assets/css/amazeui.min.css"/>
	<link rel="stylesheet" href="${base}/amazeui/assets/css/app.css"/>
	<base href="${base}/index/">
	<style type="text/css">
	input[type=text]{border-radius: 4px;}
	.input{margin-left: 8px;}
	.tpl-form-line-form select{width: 25%;float: left;}
	input[type=checkbox]{margin-left: 8px;margin-right: 2px;}
	.tpl-block{font-size: 16px;}
	body { background: white;}
	</style>
</head>
<body>
<header data-am-widget="header" class="am-header am-header-default">
    <div class="am-header-left am-header-nav">
        <a onclick="window.history.go(-1);" class="am-btn am-btn-default">
            <i class="am-icon-arrow-left"></i>
        </a>
    </div>
    <h1 class="am-header-title">
       添加房源
    </h1>
</header>

<div class="tpl-block">
  <div class="am-g">
      <div class="tpl-form-body tpl-form-line">
          <form class="am-form tpl-form-line-form" action="${base}/index/houseSave" id="loginform" name="loginform" method="post">  
<!--           	  <input type="hidden" name="ownerid" value="${user.id}" /> -->
              <div class="am-form-group am-u-sm-12">
                  <label for="name" class="am-form-label">公寓/小区名称:</label>
                  <div class="input">
                  <input type="text" class="tpl-form-input" id="name" name="name" placeholder="请输入名称" maxlength="16">
                  </div>
              </div>
               <div class="am-form-group  am-u-sm-12">
                  <label for="address" class="am-form-label">地理位置:</label>
                  <div class="input">
                	  <select name="province" id ="province" class="area">
                	  	<option value="江苏省">江苏省</option>
                	  </select> 
                	  <select name="city" id ="city" class="area">
                	  	<option value="苏州市">苏州市</option>
                	  </select>
                	  <select name="village" id ="village" class="area">
                	  	<option value="姑苏区">姑苏区</option>
                	  </select>
                	  <select name="road" id ="road" class="area">
                	  	<option value="娄葑区">娄葑区</option>
                	  </select>
                    <input type="text" class="tpl-form-input" id="address" name="address" placeholder="请输入详细地址">
                  </div>
              </div>
              <div class="am-form-group am-u-sm-12">
                  <label for="area" class="am-form-label">建筑面积:</label>
                  <div class="input" style="display: inline-block;">
                      <input type="number" class="tpl-form-input" id="area" name="area" placeholder="请输入面积" style="width: 80px;text-align: right;display: inline-block;    margin-right: 10px;"/>平方米
                  </div>
              </div>
              <div class="am-form-group am-u-sm-12">
                  <label for="area" class="am-form-label">房内电器:</label>
                  <div class="input" style="display: inline-block;font-size: 14px;">
                  	  <input type="hidden"  name="equip" id="equip" />
                  	  <#list equipList as one>
                  	  <input type="checkbox" name="e" id="e${one.id}"  value="${one.id}" >${one.key}&nbsp;
                      </#list>
                  </div>
              </div>
               <div class="am-form-group am-u-sm-12">
                  <label for="name" class="am-form-label">房产证:</label>
                  <div class="input">
                          <div class="tpl-form-file-img">
                          	  <input name="resid" type="hidden" id="residval" >
                              <img id="resid" src="${base}/amazeui/assets/img/a5.png" alt="点击上传房产证图片" class="btn">
                          </div>
                  </div>
              </div>
                                        

              <div class="am-form-group">
                 <div class="am-u-sm-9 am-u-sm-push-3">
                 	<input type="button"  value="提 交" onclick="save()" class="am-btn am-btn-primary tpl-btn-bg-color-success" />
                 </div>
             </div>
            </form>
      </div>
   </div><!-- am-g -->
</div>
<form action="${base}/util/uploadFile" method="post" name="uploadForm" enctype="multipart/form-data" id="uploadForm" class="hide" >
    <input name="pic" type="file" id="pic" class="hide"/>
</form>
</body>
<script type="text/javascript" src="${base}/js/common.js"></script>
<script src="${base}/js/jquery1.10.2.min.js" ></script>
<script src="${base}/js/jquery.form.js" ></script>
<script>
var currentPic;
jQuery(function(){
	 // 文件上传
    $(".btn").click(function(){
        currentPic = $(this)
        $("#pic").click();
    });
    $("#pic").change(function (){
        var fileName = $("#pic").val()

        var options = {
            success:  showResponse,  //处理完成的回调函数
            resetForm: true,
            //dataType:  'json'
        };
        $("#uploadForm").ajaxSubmit(options);
    });
});


function save(){
	var name = $("#name").val();
	if(name.length==0){ 
		alert("请输入公寓/小区名称"); 
		$("#name").focus(); 
		return false; 
	}
	var address = $("#address").val();
	if(address.length==0){ 
		alert("请输入详细地址"); 
		$("#address").focus(); 
		return false; 
	}
	var area = $("#area").val();
	if(area.length==0){ 
		alert("请输入面积"); 
		$("#area").focus(); 
		return false; 
	}
	var resid =  $("#residval").val();
	if(resid.length==0){ 
		alert("请上传房产证"); 
		$("#residval").focus(); 
		return false; 
	}
	var options = {
	    success:  showResponse2,  //处理完成的回调函数
	    resetForm: true
	};
	$("#loginform").ajaxSubmit(options);
}
function showResponse2(responseText)  {
	alert(responseText);
}
function showResponse(responseText)  {
	$("#"+currentPic.attr("id")+"val").val(responseText);
	currentPic.attr("src", responseText)
}
</script>
</html>
